-
-
Notifications
You must be signed in to change notification settings - Fork 359
Added BogoSort in Swift 4.1 #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added BogoSort in Swift 4.1 #161
Conversation
Welcome @CDsigma! Thanks for the contribution! You're the first person to submit Swift code to the Algorithm Archive. You correctly added the code import to the .md file, but currently it doesn't know what ...
{
"lang": "go",
"name": "Go"
},
{
"lang": "swift",
"name": "Swift"
} I don't know if we have a Swift programmer to review your code, but we will see what we can do. Your code looks pretty good, so I'm sure it will get merged soon. If you want, you can also add your name to the end of the CONTRIBUTORS.md file, but you don't have to. |
Perfect. I totally didn't catch that you only changed |
Awesome :) Thanks for your help 😊 |
One small note: you commited with a git user/email different from your GitHub one. Was this intentional? If not, feel free to fix it and force push your changes. |
|
||
|
||
func isSorted(inputArray: [Int]) -> Bool { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick 1: 2 out of 3 functions start with an empty line. I don't know which style is best, but I do know that consistency is always rule number 1 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya that's a good note I'll make the line spacing consistent in each function
|
||
|
||
|
||
func shuffle(inputArray: inout [Int]) -> [Int] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick 2: a quick Google search showed me that there is a native shuffle
function in Swift 4.2+. Maybe it's best to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a reason to use version 4.1 specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my bad, I had not seen the version was specifically 4.1, it's right there in the title -_-
But yeah, I'd like to hear the reason too then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most people who use Swift tend to use the version which comes with Xcode. Currently the stable build of Xcode uses Swift 4.1 so I thought that would be the best choice.
There is an Xcode 10 beta which uses Swift 4.2 but that won't be the stable build for a few months so until then I think Swift 4.1 is the best choice.
@Gustorn Ya I noticed that just after I committed. I didn't mean to do it but I also don't mind so I think I'll leave it 🤷 |
@CDsigma sure thing, I just thought I'd mention it since sometimes people accidentally commit with their work email (did it once or twice myself) and they'd rather not have that online. If you're OK with the current one it's all good. |
I accidentally had messed up the location of some the brackets
This update should fix the location of the brackets
Okay now I have actually formatted the brackets correctly
The squashed commit will have the right author, I think. It won't really matter in the end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you and @jiegillet figured some things out, I have some small changes that I'd like you to make. Once they're done, I think this one is ready to merge!
book.json
Outdated
"lang": "swift", | ||
"name": "Swift" | ||
}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two lines with the brackets are indented with a bunch of spaces and then 3 tabs. The file is tab indented. Try to make sure you only use tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that just committed some changes so no more spaces are used
@@ -36,6 +36,9 @@ In code, it looks something like this: | |||
{% sample lang="rs" %} | |||
[import, lang:"rust"](code/rust/bogosort.rs) | |||
{% endmethod %} | |||
{% sample lang="swift" %} | |||
[import, lang:"swift"](code/swift/bogoSort.swift) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the capitalization of the "S" in the file name. Some languages (like Java) require capitalization to match classes and such inside the files, but I'd prefer to keep everything else lowercase.
Unless it's some kind of convention in Swift. In that case, keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just updated the file name 👍
Since we all don't really know Swift, I'll just take the liberty to merge this one. The logic of the code is correct and so it shouldn't be an issue. |
Nevermind. I just found a mistake that breaks the build. You have to fix this before I can merge. |
@@ -36,6 +36,9 @@ In code, it looks something like this: | |||
{% sample lang="rs" %} | |||
[import, lang:"rust"](code/rust/bogosort.rs) | |||
{% endmethod %} | |||
{% sample lang="swift" %} | |||
[import, lang:"swift"](code/swift/bogosort.swift) | |||
{% endmethod %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's only supposed to be one {% endmethod %}
statement at the end. You have to remove the one in line 38.
Added BogoSort in Swift 4.1